package com.threeti.mecool.framework.util;

import org.dozer.DozerBeanMapper;

import com.threeti.mecool.framework.web.form.AbstractSearchCriteriaForm;

public class DynaCriteriaBuilder {
  
  public static DynaSearchCriteria buildDynaSearchCriteriaBy(Class criteriaClazz, AbstractSearchCriteriaForm sourceForm) {
    
    try {
      DynaSearchCriteria destDto = (DynaSearchCriteria)criteriaClazz.newInstance();
      DozerBeanMapper transfer = new DozerBeanMapper();
      transfer.map(sourceForm, destDto);
      
      //进行额外无法通过自动映射完成的转换(如额外的需要通过调用Service才能完成的List注入)
      //...
      
      return destDto;
      
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    
    return null;
  }
}
